<template>
    <div>
        <!-- 删除确认提示框 -->
        <el-dialog v-model="dialogVisible" title="Tips" width="30%">
            <span>此操作不可逆，确认删除吗？</span>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="dialogVisible = false">取消</el-button>
                    <el-button type="primary" @click="changeDel">
                        确认
                    </el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>

<script setup lang="ts">
import {  ref, watchEffect } from 'vue'
import { usersDel,  } from '@/API/user.api';
import { ElMessage,  } from 'element-plus'

const emit = defineEmits(['getdatalist'])
const props =defineProps({
    data:{
        type:Object,
        default:()=>{}
    }
})
console.log(props.data);

const dialogVisible = ref(false)
async function show(){
    dialogVisible.value = true
}
// 点击删除对话框确认发送请求
const changeDel = async () => {
    const res = await usersDel({ id: props.data.id })
    if (res.data.code === 1) {
        dialogVisible.value = false
        ElMessage({
            type: 'success',
            message: res.data.msg,
        })
    } else {
        ElMessage({
            type: 'info',
            message: '删除失败',
        })
    }
    emit('getdatalist','')
}
watchEffect(()=>{
    show()
})
</script>

<style scoped>

</style>